<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增收据管理')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-receipts-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">交款单位(或姓名)：</label>
                <div class="col-sm-8">
                    <input name="companyName" class="form-control" type="text" required autocomplete="off">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">收据日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="receiptDate" class="form-control" placeholder="yyyy-MM-dd" type="text" readonly required >
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">收据号：</label>
                <div class="col-sm-8">
                    <input name="receiptNo" class="form-control" type="text" placeholder="为空自动生成">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">收款方式：</label>
                <div class="col-sm-8">
                    <select name="receiptMode" class="form-control m-b" th:with="type=${@dict.getType('receipt_type')}">
                        <option value="">请选择</option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 请选择字典属性</span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">人民币：</label>
                <div class="col-sm-8">
                    <input name="receiptRmb" class="form-control" type="text" onblur="showRmbUpperCase(this);" required autocomplete="off">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">人民币大写：</label>
                <div class="col-sm-8">
                    <input name="receiptRmbUpp" class="form-control" type="text" readonly>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注事项：</label>
                <div class="col-sm-8">
                    <select name="remarkType" class="form-control m-b" th:with="type=${@dict.getType('receipt_remark_type')}">
                        <option value="">请选择</option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 请选择字典属性</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="remark" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">出纳：</label>
                <div class="col-sm-8">
                    <input name="cashier" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">经办人：</label>
                <div class="col-sm-8">
                    <input name="operator" class="form-control" type="hidden" th:field="${loginUser.userId}" readonly>
                    <input name="operator_name" class="form-control" type="text" onclick="selectUser()" th:field="${loginUser.userName}" readonly>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "system/receipts";
        $("#form-receipts-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                var _form = $('#form-receipts-add').serialize();
                _form+="&operator="+$("#userId").val();
                $.operate.save(prefix + "/add", _form);
            }
        }

        $("input[name='receiptDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        $("input[name='receiptDate']").datetimepicker('setDate', new Date()); //把要设置的默认值放入new Date()里面

        function showRmbUpperCase(obj){
            var _rmb = obj.value;
            if(!isNaN(_rmb)){
                _rmb = convertCurrency(_rmb);
                $("input[name='receiptRmbUpp']").val(_rmb);
            }
        }

        function selectUser() {
            var url = ctx+"system/user/selectUser/{id}";
            var userId = 0
            $.operate.selectUser(url, userId);
        }

    </script>
</body>
</html>